package com.kingbogo.superplayer.demo;

import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.kingbogo.superplayer.model.SuperPlayerModel;
import com.kingbogo.superplayer.view.SuperPlayerView;

/**
 * <p>
 * </p>
 *
 * @author Kingbo
 * @date 2022/3/25
 */
public class MultiVideoViewActivity extends AppCompatActivity implements View.OnClickListener {

    private static final String VIDEO_URL = "file:///android_asset/video/login.mp4";

    private SuperPlayerView playerView1;
    private SuperPlayerView playerView2;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_multi_video);

        playerView1 = findViewById(R.id.video_super_player_view1);
        playerView2 = findViewById(R.id.video_super_player_view2);

        findViewById(R.id.video_play_1_btn).setOnClickListener(this);
        findViewById(R.id.video_play_2_btn).setOnClickListener(this);

        videoPlayer(playerView1);
        videoPlayer(playerView2);
    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        if (id == R.id.video_play_1_btn) {
            videoPlayer(playerView1);
        } else if (id == R.id.video_play_2_btn) {
            videoPlayer(playerView2);
        }
    }

    private void videoPlayer(SuperPlayerView playerView) {
        SuperPlayerModel model = new SuperPlayerModel();
        model.url = VIDEO_URL;
        model.isLoop = true;
        playerView.playWithModel(model);
    }


}
